<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>iframe onload</title>
    </head>

    <body>
        <script>
            function setBody(elm) {
                document.body.innerHTML = '<div id="container">' + elm.id + '</div>';
            }
            window.setTimeout(() => {
                document.body.innerHTML = '<iframe id="test_ok" src="inner.html" onload="setBody(this);"></iframe>';
            }, 500);
        </script>
    </body>
</html>
